package com.zhengxing.jienci.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 浪遏飞舟
 * @create 2020-10-31 16:52
 * 静态资源访问
 */
@Configuration
public class FileUrlConfig implements WebMvcConfigurer {

    @Value("${uploadFile.dir}")
    private String filePath;


    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + filePath + "/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }

}
